package com.jiaoyou.baojian.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;

import com.jiaoyou.baojian.R;
import com.jiaoyou.baojian.dialog.OkDialog;
import com.jiaoyou.baojian.http.Api;
import com.jiaoyou.baojian.http.BaofangCallback;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import retrofit2.Call;

public class FeedBackActivity extends BaseActivity {

    @BindView(R.id.editText)
    EditText editText;
    @BindView(R.id.send)
    Button send;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.bind(this);

        setTitle("反馈");
    }

    @Override
    public int getContentView() {
        return R.layout.activity_feed_back;
    }

    @OnClick(R.id.send)
    public void onViewClicked() {
        String s = editText.getEditableText().toString();
        if(TextUtils.isEmpty(s))
            return;
        waiting("正在给包房客服反馈...");
        Api.getInstance().feedback(s, new BaofangCallback<String>() {
            @Override
            public void onFailure(Call call, Throwable t) {
                toast("错误：" + t.getLocalizedMessage());
            }

            @Override
            public void onSuccess(String o) {
                showOkDialog("反馈成功，感谢您对包房的支持", new OkDialog.OnClickListener() {
                    @Override
                    public void onBtnClick() {
                        onBackPressed();
                    }
                });
            }
        });
    }
}
